package com.health.work.activity;

import java.security.Identity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.health.work.R;
import com.health.work.adapter.QuestionListAdapter;
import com.health.work.utils.DefaultJSONData;
import com.health.work.utils.RequestParamtersUtil;
import com.health.work.utils.TipsUtil;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/**
 * 获取问题详情页面
 * @author star
 *
 */
public class QuestionDetailsActivity extends Activity{

	private Button back;
	private final static int SUCCESS = 0;
	private final static int FAILE = 1;
	private final static int ERROR = 2;
	private static final int NOASK = 3;
	private static final int SHOWQUESTION = 4;
	protected String errorMessage = "";
	String Id;
	private Thread thread;
	private Handler handler = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case SUCCESS:
				TipsUtil.showAlert(QuestionDetailsActivity.this, null, "数据请求成功！");
				
				break;
			case FAILE:
				TipsUtil.showAlert(QuestionDetailsActivity.this, null, "数据请求失败！");
				break;
			case ERROR:
				TipsUtil.showAlert(QuestionDetailsActivity.this, null, "未知错误！");
				break;
			case NOASK:
				TipsUtil.showAlert(QuestionDetailsActivity.this, null,
						errorMessage);
				break;
			case SHOWQUESTION:
				break;
			default:
				break;
			}

		}

	};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.question_details_layout);
		initPages();
		getData();
	}
	private void initPages(){
		
		back=(Button)findViewById(R.id.btnBack);
		back.setOnClickListener(onClickListener);
	}

	OnClickListener onClickListener=new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.btnBack:
				finish();
				break;

			default:
				break;
			}
		}
		
	};
	/**
	 * 获取问题详情
	 */
	private void getData(){
		thread=new Thread(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				new RequestParamtersUtil().GetQuestionDetail(28, new DefaultJSONData() {
					
					@Override
					public void parse(String result) throws JSONException {
						// TODO Auto-generated method stub
						
					}
					
					@Override
					public void parse(JSONObject object) throws JSONException {
						// TODO Auto-generated method stub
						
					}
					
					@Override
					public void parse(JSONArray array) throws JSONException {
						// TODO Auto-generated method stub
						
					}
				});
			}
		});
	}
}
